/*
 * Copyright (c) 2006, 2023, webrx.cn All rights reserved.
 *
 */

package cn.webrx;

import java.util.Arrays;

/**
 * <p>Project: jse2303 - ArrSort1
 * <p>Powered by webrx On 2023-07-12 11:00:51
 * <p>描述：<p>
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class ArrSort2 {
    public static void main(String[] args) {
        Integer[] ns = {1, 9, 3, 20, 35, 16, 5, 2, 0};
        System.out.println(Arrays.toString(ns));
        //升序
        Arrays.sort(ns);
        Arrays.sort(ns, (a, b) -> a - b);
        System.out.println(Arrays.toString(ns));

        //降序
        Arrays.sort(ns, (a, b) -> b - a);
        System.out.println(Arrays.toString(ns));

        //洗牌
        Arrays.sort(ns, (a, b) -> Math.random() > .5 ? 1 : -1);
        Arrays.sort(ns, (a, b) -> Math.random() > .5 ? 1 : -1);
        Arrays.sort(ns, (a, b) -> Math.random() > .5 ? 1 : -1);
        Arrays.sort(ns, (a, b) -> Math.random() > .5 ? 1 : -1);
        Arrays.sort(ns, (a, b) -> Math.random() > .5 ? 1 : -1);
        System.out.println(Arrays.toString(ns));

    }
}
